package com.smart.village.big.screen.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.smart.village.big.screen.domain.PartyFeesStatisticsVo;
import com.smart.village.big.screen.mapper.PartyFeesMapper;
import com.smart.village.big.screen.service.PartyFeesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class PartyFeesServiceImpl implements PartyFeesService {
    @Autowired
    private PartyFeesMapper partyFeesMapper;

    @Override
    public List<PartyFeesStatisticsVo> getPartyFeesStatistics(PartyFeesStatisticsVo partyFeesStatisticsVo) {
        List<PartyFeesStatisticsVo> partyFeesStatistics = partyFeesMapper.getPartyFeesStatistics(partyFeesStatisticsVo);
        for (PartyFeesStatisticsVo partyFeesStatistic : partyFeesStatistics) {
            if (partyFeesStatistic.getFeeCnt() > 0) {
                partyFeesStatistic.setFeeStatus("已交");
            } else {
                partyFeesStatistic.setFeeStatus("未交");
            }
        }
        return partyFeesStatistics;
    }

    @Override
    public List<JSONObject> getPartyFeesStatisticsDetail(PartyFeesStatisticsVo partyFeesStatisticsVo) {
        return partyFeesMapper.getPartyFeesStatisticsDetail(partyFeesStatisticsVo);
    }

    @Override
    public List<JSONObject> getPartyFeesByPartyMemberAndYear(HashMap param) {
        return partyFeesMapper.getPartyFeesByPartyMemberAndYear(param);
    }

    @Override
    public List<JSONObject> getPartyFeesDetailByPartyMemberAndYear(HashMap param) {
        return partyFeesMapper.getPartyFeesDetailByPartyMemberAndYear(param);
    }

    @Override
    public List<JSONObject> getMicroManagerPartyFees(HashMap param) {
        return partyFeesMapper.getMicroManagerPartyFees(param);
    }

    @Override
    public List<JSONObject> getMicroManagerPartyFeesDetail(HashMap param) {
        return partyFeesMapper.getMicroManagerPartyFeesDetail(param);
    }

    @Override
    public JSONObject getMicroManagerPartyFeesDetailMore(HashMap param) {
        JSONObject jsonObject = new JSONObject();
        PageHelper.startPage(Integer.parseInt(param.get("pageNum").toString()),Integer.parseInt( param.get("pageSize").toString()));
        List<JSONObject> list = partyFeesMapper.getMicroManagerPartyFeesDetailMore(param);
        Page<JSONObject> page = (Page<JSONObject>) list;
        jsonObject.put("total", page.getTotal());
        jsonObject.put("list", list);
        return jsonObject;
    }
}
